<template>
	<view class="cropper-wrapper">
		<ksp-cropper mode="ratio" :width="width" :height="height" :url="url" @cancel="back" @ok="onok"></ksp-cropper>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url: '',
				width: 300,
				height: 300
			};
		},
		onLoad(option) {
			this.setData({
				url: option.url,
				width: option.width - 0,
				height: option.height - 0
			})
		},
		methods: {
			onok(e) {
				const eventChannel = this.getOpenerEventChannel();
				eventChannel.emit('getNew', {
					src : e.path
				});
				this.back()
			},
			back() {
				uni.navigateBack({
					delta: 0
				});
			}
		}
	};
</script>
<style>
	@import './index.css';
</style>
